#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nyu_scope.h"

NyuScope *nyu_scope_new(NyuScope *parent)
{
    NyuScope *self;

    self = (NyuScope *)malloc(sizeof(NyuScope));
    if (!self) {
        perror("cannot alloc NyuScope!");
        abort();
    }

    self->parent = parent;
    self->scope_var_list = NULL;
    self->blk = NULL;
    self->target = 0;

    return self;
}

NyuScopeVarList *nyu_scope_var_list_prepend(NyuScopeVarList *list,
                                            NyuVarData **ref)
{
    NyuScopeVarList *l;

    l = (NyuScopeVarList *)malloc(sizeof(NyuScopeVarList));
    if (!l) {
        perror("cannot alloc NyuScopeVarList!");
        abort();
    }

    l->next = list;
    l->ref = ref;

    return l;
}
